<?php

defined('IN_PHPCMS') or exit('No permission resources.');

class index {

    private $db_content;

    public function __construct() {
        $this->db_content = pc_base::load_model('content_model');
    }

    public function init() {
        $t = isset($_GET['t']) ? (int)$_GET['t'] : 1;
        $q = isset($_GET['q']) ? trim($_GET['q']) : '';
        $q = safe_replace($q);
        $type = intval($_GET['type']);
        switch ($t) {
            case 2:
                $sql = "select * from v9_classmany where status=99 and catid=2 and (title like '%$q%' or small_content like '%$q%')";
                break;
            case 3:
                $sql = "select * from v9_SuperStar where title like '%$q%'";
                break;
            case 4:
                $sql = "select * from v9_team where title like '%$q%' or small_content like '%$q%'";
                break;
            default:
                $sql = "select * from v9_classmany where status=99 and catid=1 and (title like '%$q%' or small_content like '%$q%')";
                if ($q == "免费") {
                    $sql = "select * from v9_classmany where status=99 and catid=1 and price_cut=0";
                }
        }


        $this->db_content->query($sql);
        $arr = $this->db_content->fetch_array();


        include template('content', 'search');
    }
}